{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "66364a7d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Please input balance:7999\n",
      "The products list is as follows\n",
      "-----productsList-----\n",
      "The number: 1 : ['iphone', 6888]\n",
      "Please choose the numbber1\n",
      "You have successfully purchaseed!\n",
      "Your account balance is: 1111\n",
      "The number: 2 : ['ipad', 2999]\n",
      "Please choose the numbber2\n",
      "Your account balance is insufficient!\n",
      "Your account balanceis: 1111\n",
      "You can press any button to continue,or input 'n'toleave:n\n",
      "Your account balance is: 1111\n",
      "Your shopping list is as follows:\n",
      "-----clothesList-----\n",
      "The number: 3 : ['mac', 13999]\n",
      "Please choose the numbber3\n",
      "Your account balance is insufficient!\n",
      "Your account balanceis: 1111\n",
      "You can press any button to continue,or input 'n'toleave:h\n"
     ]
    }
   ],
   "source": [
    "balance=int(input(\"Please input balance:\"))\n",
    "products=[[\"iphone\",6888],[\"ipad\",2999],[\"mac\",13999]]\n",
    "haveGoods=[balance,[]]\n",
    "flag=True\n",
    "while flag:\n",
    "    print(\"The products list is as follows\")\n",
    "    print(\"-----productsList-----\")\n",
    "    i=1;\n",
    "    for c in products:\n",
    "        print('The number:',i,\":\",c)\n",
    "        i+=1\n",
    "        code=int(input(\"Please choose the numbber\"))\n",
    "        if products[code-1][1]<=haveGoods[0]:\n",
    "            haveGoods[0]-=products[code-1][1]\n",
    "            print(\"You have successfully purchaseed!\")\n",
    "            print(\"Your account balance is:\",haveGoods[0])\n",
    "        else:\n",
    "            print(\"Your account balance is insufficient!\")\n",
    "            print(\"Your account balanceis:\",haveGoods[0])\n",
    "            judge=input(\"You can press any button to continue,or input 'n'toleave:\")\n",
    "            if judge==\"n\":\n",
    "                flag=False\n",
    "                print(\"Your account balance is:\",haveGoods[0])\n",
    "                print(\"Your shopping list is as follows:\")\n",
    "                print(\"-----clothesList-----\")\n",
    "                for h in haveGoods[1]:\n",
    "                    print(h)\n",
    "    \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c5d1931b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d539cd57",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
